package com.xiaode.controller.app.teacher.example;

import com.jfinal.aop.Inject;
import com.jfinal.core.Controller;
import com.jfinal.core.Path;
import com.jfinal.ext.cors.EnableCORS;
import com.jfinal.kit.Ret;
import com.xiaode.common.model.Admin;
import com.xiaode.util.apidoc.annotation.Api;
import com.xiaode.util.apidoc.annotation.ApiOper;
import com.xiaode.util.apidoc.annotation.ApiPara;

import javax.validation.constraints.Size;

/**
 * 登录服务
 */
@Path("/tExample")
@Api("老师榜样相关服务")
@EnableCORS
public class ExampleController extends Controller {

    @Inject
    private ExampleService service;
    
	/**
	 * 需要审核的榜样
	 */
	@ApiOper("需要审核的榜样")
	public void needExamineExample(
			@Size(min = 1) @ApiPara(value = "page", notes = "页码")Integer page,
			@Size(min = 1) @ApiPara(value = "limit", notes = "每页数量")Integer limit,
			@ApiPara(value = "state",notes = "状态")Integer state,
			@ApiPara(value = "keyWord",notes = "keyWord")String keyWord) throws Exception{
		Admin admin = getAttr("user");
    	Ret ret = service.needExamineExample(admin.getId(), page, limit,state,keyWord);
    	renderJson(ret);
    }


	/**
	 * 删除榜样申请
	 */
//    @ApiOper("删除榜样申请")
//	public void delExamplApply(
//			@Size @ApiPara(value = "exId",notes = "榜样ID")Integer exId,
//			@ApiPara(value = "reason",notes = "删除理由")String reason)throws Exception{
//    	Admin admin = getAttr("user");
//		Ret ret = service.delExamplApply(admin.getId(), exId, reason);
//		renderJson(ret);
//	}

	/**
	 * 审核
	 */
	@ApiOper("审核榜样")
	public void examineExample(
			@Size @ApiPara(value = "exampleId", notes = "榜样id")Integer exampleId,
			@Size @ApiPara(value = "state", notes = "审核状态1.审核中,2.组长待审核,3.导师审核不通过,4.组长审核通过 5.组长拒绝")Integer state,
			@ApiPara(value = "examineReason",notes = "审核原因") String examineReason) throws Exception{
		Admin admin = getAttr("user");
    	Ret ret = service.examineExample(admin, exampleId, state,examineReason);
    	renderJson(ret);
    }
	
	/**
	 * 已有的榜样列表
	 */
	@ApiOper("已有的榜样列表")
	public void examplePage(
			@Size @ApiPara(value = "page", notes = "页码")Integer page, 
			@Size @ApiPara(value = "limit", notes = "每页数量")Integer limit,
			@ApiPara(value = "state",notes = "榜样状态 1.审核中,2.审核通过,3.未通过")Integer state,
			@ApiPara(value = "keyWord",notes = "关键词")String keyWord) throws Exception{
    	Ret ret = service.examplePage(page, limit, state,keyWord);
    	renderJson(ret);
    }
	
//
//	/**
//	 * 老师下学生的榜样任务
//	 */
//	@ApiOper("老师下学生的榜样任务")
//	public void exampleTaskPage(
//			@Size @ApiPara(value = "page", notes = "页码")Integer page,
//			@Size @ApiPara(value = "limit", notes = "每页数量")Integer limit) throws Exception{
//		Admin admin = getAttr("user");
//    	Ret ret = service.exampleTaskPage(admin.getId(), page, limit);
//    	renderJson(ret);
//    }
	/**
	 * 审核榜样任务
	 */
	@ApiOper("审核榜样任务")
	public void examineTask(
			@Size @ApiPara(value = "setId", notes = "榜样任务id")Integer setId,
			@Size @ApiPara(value = "state", notes = "审核状态1.提交审核,2审核通过,3.审核未通过")Integer state,
			@ApiPara(value = "reason",notes = "拒绝原因")String reason) throws Exception{
		Admin admin = getAttr("user");
		Ret ret = service.examineTask(admin.getId(), setId, state,reason);
		renderJson(ret);
	}

	/**
	 * 榜样详情页
	 */
	@ApiPara("榜样详情页")
	public void exampleDetailPage(@Size @ApiPara(value = "studentId",notes = "学生id")Integer studentId)throws Exception{
		Admin admin = getAttr("user");
		Ret ret = service.exampleDetailPage(admin.getId(),studentId);
		renderJson(ret);
	}

}